<ion-view title="供应商" show-tabs="true">

  <ion-nav-buttons side="right">
    <button class="button button-icon ion-ios-search" ng-click="showFilter();"></button>
    <button class="button button-icon ion-android-add" ng-click="openModal();"></button>
  </ion-nav-buttons>

  <section class="bar bar-header bar-royal search-box item-input-inset">
    <label class="item-input-wrapper">
      <i class="icon ion-ios-search placeholder-icon"></i>
      <input type="search" placeholder="搜索" ng-model="filterText">

    </label>
    <button class="button button-clear" ng-click="cancelFilter()">
      取消
    </button>
  </section>

  <ion-content class="has-header has-footer">
    <ion-list>

    	<ion-item class="margin-bottom-large item-icon-left item-icon-right" href="#/contacts">
    		<i class="icon ion-iphone assertive"></i>
	     	手机通讯录
	     	<i class="icon ion-ios-arrow-right"></i>
    	</ion-item>

      <div ng-repeat="(label,group) in suppliersGroup" class="accordion-list">
  	   <ion-item ng-click="toggleGroup(group)" ng-class="{'royal': group.isExpend}" ng-if="group.list.length" class="margin-top-large">
          <i class="icon-block" ng-class="group.isExpend ? 'ion-arrow-down-b' : 'ion-arrow-right-b'"></i>
          {{label}}
          <span class="item-note padding-right">{{group.list.length}} </span>
        </ion-item>
        <ion-item class="sub-item" ng-repeat="supplier in group.list | filter : {company : filterText}" ng-show="group.isExpend">
          <div class="item-row arrow right-bottom-arrow" ng-class="{on: isItemShown(supplier)}" ng-click="toggleItem(supplier)">
            <div>{{supplier.company}}</div>
            <div class="padding-top meta">
              <span>联系人：{{supplier.contact_list[0].name}}</span>
            </div>
          </div>
          <div class="item-accordion" ng-if="isItemShown(supplier)">
            <div class="button-bar">
              <a class="button button-icon" href="#/supplier-{{supplier._id}}">
                <i class="icon icon-top ion-ios-eye-outline royal"></i>详情
              </a>
              <a class="button button-icon" ng-click="delete(supplier._id)">
                <i class="icon icon-top ion-ios-trash-outline royal"></i>删除
              </a>
              <a class="button button-icon" href="#/supplier-{{supplier._id}}?isEdit=1">
                <i class="icon icon-top ion-ios-compose-outline royal"></i>编辑
              </a>
              <a class="button button-icon" href="tel:{{supplier.tel}}">
                <i class="icon icon-top ion-ios-telephone-outline royal"></i>拨号
              </a>
            </div>
          </div>
        </ion-item>
      </div>
    </ion-list>
  </ion-content>
</ion-view>
